/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package com.lswms.controller;

import java.util.List;

import com.lswms.annotation.Login;
import com.lswms.annotation.LoginUser;
import com.lswms.common.redis.RedisUtils;
import com.lswms.common.utils.Result;
import com.lswms.common.validator.ValidatorUtils;
import com.lswms.dto.YnUserDTO;
import com.lswms.dto.vo.req.BankcardReq;
import com.lswms.dto.vo.req.DcConfirmUserInfoReq;
import com.lswms.dto.vo.req.DcDataDetailReq;
import com.lswms.dto.vo.req.DcIndexDataReq;
import com.lswms.dto.vo.req.LoginReq;
import com.lswms.dto.vo.req.UpdateUserInfoReq;
import com.lswms.dto.vo.resp.DcDataDetailResp;
import com.lswms.dto.vo.resp.DcDataInfoResp;
import com.lswms.dto.vo.resp.DcIndexDataResp;
import com.lswms.dto.vo.resp.LoginResp;
import com.lswms.dto.vo.resp.UpDateInfo;
import com.lswms.entity.YnUserEntity;
import com.lswms.redis.SysParamsRedis;
import com.lswms.service.YnDcProdService;
import com.lswms.service.YnUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;



















import javax.servlet.http.HttpServletRequest;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import springfox.documentation.annotations.ApiIgnore;

import com.alibaba.fastjson.JSON;

/**
 * 代超产品接口
 *
 * @author Mark sunlightcs@gmail.com
 */
@RestController
@RequestMapping("/api/prod")
@Api(tags="DC产品接口")
@Slf4j
public class YnDcProdController {
	
    @Autowired
    private SysParamsRedis sysParamsRedis;
    
    @Autowired
    private YnDcProdService ynDcProdService;

    /**
     * 首页两个数据
     * @param dto
     * @param request
     * @return
     */
    @PostMapping("dcIndexData")
    @ApiOperation("首页两个数据")
    public Result<List<DcIndexDataResp>> dcIndexData(@RequestBody DcIndexDataReq dto,HttpServletRequest request){
    	log.info("首页两个数据：参数：{}",JSON.toJSONString(dto));
        List<DcIndexDataResp> resp = ynDcProdService.dcIndexData(dto);
        log.info("首页两个数据：返回：{}",JSON.toJSONString(resp));
        return new Result<List<DcIndexDataResp>>().ok(resp);
    }

    /**
     * 产品列表
     * @param dto
     * @param request
     * @return
     */
    @PostMapping("dcDataList")
    @ApiOperation("产品列表")
    public Result<List<DcDataInfoResp>> dcDataList(HttpServletRequest request){
        List<DcDataInfoResp> resp = ynDcProdService.dcDataList();
        log.info("产品列表：返回：{}",JSON.toJSONString(resp));
        return new Result<List<DcDataInfoResp>>().ok(resp);
    }
    
    /**
     * 产品详情
     * @param dto
     * @param request
     * @return
     */
    @PostMapping("dcDataDetail")
    @ApiOperation("产品详情")
    public Result<DcDataDetailResp> dcDataDetail(@RequestBody DcDataDetailReq dto,HttpServletRequest request){
    	log.info("产品详情：参数：{}",JSON.toJSONString(dto));
    	DcDataDetailResp resp = ynDcProdService.dcDataDetail(dto);
        log.info("产品详情：返回：{}",JSON.toJSONString(resp));
        return new Result<DcDataDetailResp>().ok(resp);
    }
    /**
     * 产品详情提交用户信息
     * @param dto
     * @param request
     * @return
     */
    @PostMapping("dcConfirmUserInfo")
    @ApiOperation("产品详情提交用户信息")
    @Login
    public Result<Object> dcConfirmUserInfo(@RequestBody DcConfirmUserInfoReq dto,
    		@ApiIgnore @LoginUser YnUserEntity ynuser,HttpServletRequest request){
    	log.info("产品详情提交用户信息：参数：{}",JSON.toJSONString(dto));
    	ynDcProdService.dcConfirmUserInfo(dto,ynuser);
        log.info("产品详情提交用户信息");
        return new Result<Object>();
    }

}